import { IToolTipItem } from "../../../../../com/mui/manager/IToolTipItem";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { GTextFormat } from "../../../../common/GTextFormat";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { EffectManager } from "../../../manager/EffectManager";
import { ToolTipsManager } from "../../../../../com/mui/manager/ToolTipsManager";
import { GLoadedButton } from "../../../../../com/mui/controls/GLoadedButton";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
type int = number;
//class WuXingImgFont
    
    export  class WuXingImgFont /* flash.display.Sprite */ implements IToolTipItem
    {
        constructor(arg1: string, arg2: int, arg3: Boolean=false, arg4: string="", arg5: Boolean=true)
        {
            
            this._imgName = arg1;
            this._width = arg2;
            this._loadedHelp = arg3;
            this._txt = arg4;
            this._bg = arg5;
            this.initUI();
            this.buttonMode = true;
            return;
        }

        protected initUI(): void
        {
            if (this._bg) 
            {
                this._bgBmp = ObjCreate.createBg(0, 4, this.width, 16, this, ImagesConst.FightingStrgBg);
            }
            if (this._loadedHelp) 
            {
                this._imgBtn = ObjCreate.createGLoadedButton(this._imgName, 0, 2, 19, 18, this);
            }
            else 
            {
                this._imgBmp = GlobalClass.getBitmap(this._imgName);
                this._imgBmp.y = -4;
                addChild(this._imgBmp);
            }
            var loc1=new GTextFormat("", 12, 16776960);
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._textField = ObjCreate.createTextField("", 0, 3, this.width, 20, this, loc1);
            this._textField.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._textField.mouseEnabled = false;
            this.updateTxt(this._txt);
            return;
        }

        public updateTxt(arg1: string): void
        {
            this._txt = arg1;
            this._textField.htmlText = HTMLUtil.addColor(arg1, "#ffff00");
            return;
        }

        public updateCompare(arg1: int): void
        {
            if (arg1 > 0) 
            {
                if (!this._compareBmp) 
                {
                    this._compareBmp = GlobalClass.getBitmap(ImagesConst.RangeRaise);
                }
                if (!contains(this._compareBmp)) 
                {
                    addChild(this._compareBmp);
                }
                this._compareBmp.x = this.width - this._compareBmp.width - 4;
                this._compareBmp.y = 4;
                EffectManager.glowFilterReg(this._compareBmp);
            }
            else if (this._compareBmp) 
            {
                EffectManager.glowFilterUnReg(this._compareBmp);
            }
            return;
        }

        public dispose(): void
        {
            if (this._compareBmp) 
            {
                EffectManager.glowFilterUnReg(this._compareBmp);
                if (this._compareBmp.parent) 
                {
                    removeChild(this._compareBmp);
                }
            }
            return;
        }

        public /* override */ get width(): number
        {
            return this._width;
        }

        public get toolTipData()
        {
            return this._tooltipData;
        }

        public set toolTipData(arg1)
        {
            if (arg1 == null || arg1 == "") 
            {
                ToolTipsManager.unregister(this);
            }
            else 
            {
                ToolTipsManager.register(this);
            }
            this._tooltipData = arg1;
            return;
        }

        /* internal */ /* var */_imgName: string;

        /* internal */ /* var */_width: int;

        /* internal */ /* var */_loadedHelp: Boolean;

        /* internal */ /* var */_txt: string;

        /* internal */ /* var */_imgBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_imgBtn: GLoadedButton;

        /* internal */ /* var */_bgBmp: ScaleBitmap;

        /* internal */ /* var */_textField: Object /* flash.text.TextField */;

        /* internal */ /* var */_bg: Boolean;

        /* internal */ /* var */_compareBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tooltipData;
    }
